# Copyright 2021 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

load("//build_tools/bazel:enforce_glob.bzl", "enforce_glob")
load("//build_tools/bazel:iree_check_test.bzl", "iree_check_single_backend_test_suite")

package(
    features = ["layering_check"],
    licenses = ["notice"],  # Apache 2.0
)

ALL_SRCS = enforce_glob(
    # keep sorted
    [
        "collapse_shape.mlir",
        "concat.mlir",
        "expand_shape.mlir",
        "extract_slice.mlir",
        "tensor_cast.mlir",
        "tensor_insert_slice.mlir",
    ],
    include = ["*.mlir"],
    exclude = [],
)

iree_check_single_backend_test_suite(
    name = "check_llvm-cpu_local-task",
    srcs = ALL_SRCS,
    compiler_flags = ["--iree-llvmcpu-target-cpu=generic"],
    driver = "local-task",
    target_backend = "llvm-cpu",
)

iree_check_single_backend_test_suite(
    name = "check_vmvx_local-task",
    srcs = ALL_SRCS,
    driver = "local-task",
    target_backend = "vmvx",
)

iree_check_single_backend_test_suite(
    name = "check_cuda",
    srcs = ALL_SRCS,
    driver = "cuda",
    tags = [
        "noasan",
        "nomsan",
        "notsan",
        "noubsan",
        "requires-gpu-nvidia",
    ],
    target_backend = "cuda",
)

iree_check_single_backend_test_suite(
    name = "check_rocm_hip",
    srcs = ALL_SRCS,
    driver = "hip",
    target_backend = "rocm",
)

SPIRV_SRCS = enforce_glob(
    # keep sorted
    [
        "collapse_shape.mlir",
        "concat.mlir",
        "expand_shape.mlir",
        "extract_slice.mlir",
        "tensor_cast.mlir",
        "tensor_insert_slice.mlir",
    ],
    include = ["*.mlir"],
    exclude = [],
)

iree_check_single_backend_test_suite(
    name = "check_metal-spirv_metal",
    srcs = SPIRV_SRCS,
    driver = "metal",
    target_backend = "metal-spirv",
)

iree_check_single_backend_test_suite(
    name = "check_vulkan-spirv_vulkan",
    srcs = SPIRV_SRCS,
    driver = "vulkan",
    target_backend = "vulkan-spirv",
)
